package zhh.tangbao.commodity.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import zhh.tangbao.commodity.dto.CommodityMachineStockUpdateDto;
import zhh.tangbao.commodity.dto.MachineQueryDto;
import zhh.tangbao.commodity.dto.MachineStockQueryDto;
import zhh.tangbao.commodity.entity.CommodityMachineStock;
import zhh.tangbao.commodity.vo.CommodityMachineStockVo;
import zhh.tangbao.commodity.vo.StockVo;
import zhh.tangbao.commodity.vo.stock.CartStockVo;
import zhh.tangbao.machine.vo.StockInfo;
import zhh.tangbao.system.dto.BaseEntityUpdateDto;
import zhh.tangbao.system.entity.PagerEntity;
import zhh.tangbao.wechat.dto.replenishment.ReplenishmentMachineStockQueryDto;
import zhh.tangbao.wechat.vo.replenishment.ReplenishmentMachineStockVo;

import java.util.Collection;
import java.util.List;

/**
 * <p>
 *     描述
 * </p>
 * @author 粥灰灰
 * <p>2023/3/3</p>
 */

@Repository
@Mapper
public interface CommodityMachineStockDao extends BaseMapper<CommodityMachineStock> {

    /**
     * 售卖机贩卖的商品的基础信息列表，无需展示剩余数量之类的信息
     * @param dto 查询条件
     * @return
     */
    List<StockVo> pageStockVo(MachineQueryDto dto);

    Long count(MachineQueryDto dto);

    /**
     * 减少某一种库存的商品数量
     */
    int reduceStockTotalRemainCount(@Param("list") List<CommodityMachineStockUpdateDto> list, @Param("ids") List<Integer> ids);

    int reduceStockToBeSoldCount(@Param("list") List<CommodityMachineStockUpdateDto> list, @Param("ids") List<Integer> ids);



    int batchDeleteByCommodityEntityId(@Param("commodityEntityIds") List<String> commodityEntityIds, @Param("dto") BaseEntityUpdateDto dto);

    List<CommodityMachineStockVo> listMachineStockInfo(@Param("dto") MachineStockQueryDto dto);

    int deleteStockDataByStockIds(@Param("ids") List<Integer> ids);

    int insertBatchSomeColumn(Collection<CommodityMachineStock> stocks);

    List<CartStockVo> listCartStockVoByStockIds(@Param("ids") List<Integer> stockId);

    List<StockInfo> listStockInfoByIds(@Param("ids") List<Integer> ids);

    List<ReplenishmentMachineStockVo> listReplenishmentMachineStockVos(@Param("pager") PagerEntity<ReplenishmentMachineStockVo> pager,@Param("dto") ReplenishmentMachineStockQueryDto dto);

    Long countReplenishmentMachineStockVos(@Param("dto") ReplenishmentMachineStockQueryDto dto);
}
